/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef MAREKBOT_H
#define MAREKBOT_H

#include "Object.h"
#include "Shapes.h"
#include "URG.h"
#include "Sick.h"
#include "SonarSet.h"
#define GIMI_CLIENT_API 20000
#include "gimi.h"
#include "../MaCI/interfaces/SpeedCtrl/SpeedCtrlServer.hpp"
#include "../MaCI/interfaces/SpeedCtrl/SpeedCtrlTypes.hpp"
#include "../MaCI/interfaces/Position/PositionServer.hpp"
#include "../MaCI/interfaces/Position/PositionTypes.hpp"

/*
Class defining simplified ode model for Marekbot.

dimensions for model are given in Marekbot_settings.h
*/

class CMarekbot : public CObject
{
  public:
    CMarekbot(CWorld* World, float x, float y, float heading, std::string name,
              std::string MaCIGroup);
    ~CMarekbot();

    void Activate();

    void Update(float StepSize);

    void OnCollision(CPrimitive *primitive, int numc, dContact *contacts, CPrimitive *primitive2);

    void Draw();

    //set motor speeds
    void SetSpeed(float speed, float angularSpeed, float acceleration);//, float angularAcceleration);

    static CObject* LoadMLMA(CWorld *world, xmlNode *node);
    
  private:
    std::string name;
    std::string MaCIGroup;
    
    CBox *Hull;
    //CCylinder *Bumper;
    CCylinder *RWheel, *LWheel;
    CSphere *Caster;


    dJointID RMotor, LMotor, CasterJoint;
    CURG *LaserScanner;
    //CSick *LaserScanner;
    CSonarSet *Sonars;
    TMaterial WheelMaterial, HullMaterial;

    gimi::GIMI gimi;
    MaCI::MaCICtrl::CMaCICtrlServer mcs;
    gim::binbag::CBinBag binbag;
    MaCI::SpeedCtrl::CSpeedCtrlServer SpeedCtrlServer;
    MaCI::SpeedCtrl::CSpeedCtrlData SpeedCtrlData;
    MaCI::Position::CPositionServer PositionServer;
    float iSpeed;
    float iAngularSpeed;
    float positionTimer;
    
    void connectGIMI();

};

#endif //MAREKBOT_H
